package tcc.controller;

import java.util.List;

import tcc.model.colony.Colony;
import tcc.model.dao.ProdutoDao;
import tcc.model.entities.ProdutoEntity;
import tcc.view.graph.GraphDisplay;

/**
 * Provides communication between the server and client
 * @author Gabriel Pacheco
 *
 */
public class SmartMarketController {

	public void control(List<String> list){
		Colony colony = new Colony();
		int option;
		String route = "";
		GraphDisplay gd = new GraphDisplay(colony); //REMOVER
		
		/**
		 * case 1: route from entrance to all goals
		 * case 2: route from actual position to cashier
		 * case 3: product description
		 */
		switch(Integer.parseInt(list.get(0))){
		case 1: route = colony.antStart(colony.fromList, colony.getGraph().getEntranceVertex());
				System.out.println(route); //REMOVER
				System.out.println("Distancia " + colony.getBestRouteDistance()); //REMOVER
				gd.drawGraph(); //REMOVER
			break;
		case 2: colony.getGraph().updateActualVertex(list.get(2));
				route = colony.antStart(colony.toCashier, colony.getGraph().getActualVertex()/*actualVertex*/);
				System.out.println(route); //REMOVER
				System.out.println("Distancia " + colony.getBestRouteDistance()); //REMOVER
				gd.drawGraph(); //REMOVER
			break;
		case 3: ProdutoDao pd = new ProdutoDao(); 
				List<ProdutoEntity> lista = pd.getProdutoInfo(list.get(1));
				
				for(ProdutoEntity pe : lista) {
					System.out.println(pe.toString());
				}
			break;
		}
		
	}
}
